using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UwinEducation.Domain.Entities;
using UwinEducation.Shared.Enums;
using UwinEducation.Shared.Models;

namespace UwinEducation.Domain.IRepositories
{
    /// <summary>
    /// 学生课表详情仓储接口
    /// </summary>
    public interface IStudentScheduleDetailsRepository : IRepository<StudentScheduleDetails, Guid>
    {
        /// <summary>
        /// 获取订单详情下的所有课表详情
        /// </summary>
        /// <param name="orderDetailId">订单详情ID</param>
        /// <returns>学生课表详情列表</returns>
        Task<List<StudentScheduleDetails>> GetByOrderDetailIdAsync(Guid orderDetailId);

        /// <summary>
        /// 获取教师课表详情下的所有学生课表
        /// </summary>
        /// <param name="teacherScheduleDetailsId">教师课表详情ID</param>
        /// <returns>学生课表详情列表</returns>
        Task<List<StudentScheduleDetails>> GetByTeacherScheduleDetailsIdAsync(Guid teacherScheduleDetailsId);

        Task<List<StudentScheduleDetails>> GetByTeacherScheduleDetailsIdAsync(List<Guid> teacherScheduleDetailsIds,Guid? studentId);

        /// <summary>
        /// 根据状态获取学生课表详情
        /// </summary>
        /// <param name="status">课表状态</param>
        /// <returns>学生课表详情列表</returns>
        Task<List<StudentScheduleDetails>> GetByStatusAsync(ScheduleStatus status);

        /// <summary>
        /// 获取指定时间范围内的学生课表详情
        /// </summary>
        /// <param name="orderDetailId">订单详情ID</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>学生课表详情列表</returns>
        Task<List<StudentScheduleDetails>> GetByDateRangeAsync(Guid orderDetailId, DateTime startTime, DateTime endTime);

        /// <summary>
        /// 批量添加学生课表详情
        /// </summary>
        /// <param name="details">学生课表详情列表</param>
        Task AddRangeAsync(List<StudentScheduleDetails> details);

        /// <summary>
        /// 批量更新学生课表详情
        /// </summary>
        /// <param name="details">学生课表详情列表</param>
        Task UpdateRangeAsync(List<StudentScheduleDetails> details);

        /// <summary>
        /// 批量删除学生课表详情
        /// </summary>
        /// <param name="details">学生课表详情列表</param>
        Task DeleteRangeAsync(List<StudentScheduleDetails> details);

        /// <summary>
        /// 检查时间冲突
        /// </summary>
        /// <param name="orderDetailId">订单详情ID</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="excludeId">需要排除的ID</param>
        /// <returns>是否存在冲突</returns>
        Task<bool> HasTimeConflictAsync(Guid orderDetailId, DateTime startTime, DateTime endTime, Guid? excludeId = null);

        /// <summary>
        /// 分页查询学生课表详情
        /// </summary>
        /// <param name="request">分页请求</param>
        /// <returns>分页结果</returns>
        Task<PagedResult<StudentScheduleDetails>> GetPagedAsync(StudentScheduleDetailsPageRequest request);

        /// <summary>
        /// 根据学生ID和教师课表ID获取学生课表详情
        /// </summary>
        /// <param name="studentId">学生ID</param>
        /// <param name="teacherScheduleDetailsId">教师课表ID</param>
        /// <returns>学生课表详情</returns>
        Task<StudentScheduleDetails> GetByOrderDetailIdAndTeacherScheduleIdAsync(Guid orderDetailId, Guid teacherScheduleDetailsId);
        
        /// <summary>
        /// 获取教师课表组已使用容量
        /// </summary>
        /// <param name="teacherScheduleId">教师课表组ID</param>
        /// <returns>已使用容量</returns>
        Task<int> GetUsedCapacityByTeacherScheduleIdAsync(Guid teacherScheduleId,Guid? studentId);

        /// <summary>
        /// 根据学生ID和教师课表详情ID获取学生课表详情
        /// </summary>
        /// <param name="studentId">学生ID</param>
        /// <param name="teacherScheduleDetailsId">教师课表详情ID</param>
        /// <returns>学生课表详情</returns>
        Task<StudentScheduleDetails> GetByStudentIdAndTeacherScheduleDetailsIdAsync(Guid studentId, Guid teacherScheduleDetailsId);

        /// <summary>
        /// 根据学生ID获取学生课表详情
        /// </summary>
        /// <param name="studentId">学生ID</param>
        /// <returns>学生课表详情列表</returns>
        Task<List<StudentScheduleDetails>> GetByStudentIdAsync(Guid studentId, DateTime startTime, DateTime endTime);
    }
} 